import * as api from '../api';

const userApi = {

  find: async (id: string) => {
    return api.GET('/api/user/find/:id', { id }, null);
  },

  findUsers: async (ids: string[]) => {
    const data = { ids: ids.join(',') };
    return api.GET('/api/user/findUsers', null, data);
  },

  query: async (keyword: string, active: string, locked: string, superuser: string, type: string, pageNumber: number, pageSize: number) => {
    const data = {
      keyword,
      active,
      locked,
      superuser,
      type,
      pageNumber,
      pageSize
    };
    return api.GET('/api/user/query', null, data);
  },

  queryUsers: async (keyword: string, maxSize: number) => {
    const data = {
      keyword,
      maxSize
    };
    return api.GET('/api/user/queryUsers', null, data);
  },

  save: async (data: any) => {
    return api.POST('/api/user/save', null, data);
  },

  delete: async (id: string) => {
    return api.DELETE('/api/user/delete/:id', { id }, null);
  },

  updateUserInfo: async (data: any) => {
    return api.POST('/api/user/updateUserInfo', null, data);
  },

  changePassword: async (data: any) => {
    return api.POST('/api/user/changePassword', null, data);
  }

};

export default userApi;
